package com.kasax.plugin.shadow.visitor

import com.kasax.plugin.shadow.utils.LogUtils
import org.objectweb.asm.MethodVisitor
import org.objectweb.asm.Opcodes

class LifecycleMethodVisitor extends MethodVisitor implements Opcodes {
    private final String methodName

    LifecycleMethodVisitor(MethodVisitor mv, String methodName) {
        super(Opcodes.ASM7, mv)
        this.methodName = methodName
    }

    @Override
    void visitCode() {
        super.visitCode()
        LogUtils.d("LifecycleMethodVisitor", "--- $methodName ---")
        mv.visitLdcInsn("LifecycleMethodVisitor")
        mv.visitLdcInsn("--- $methodName ---")
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "android/util/Log", "d", "(Ljava/lang/String;Ljava/lang/String;)I", false)
    }
}
